package webqem.wave.gadget.napkin
{
	import flash.display.Graphics;
	
	import mx.core.UIComponent;

	public class BrushCursor extends UIComponent
	{
		private var _size:Number = 1;
		private var _minGap:Number = 5;
		private var _hairLength:Number = 10;
		private var _colour:uint = 0;
		
		
		
		public function BrushCursor()
		{
			super();
			this.mouseEnabled = false;
		}
		
		public function get colour():uint
		{
			return _colour;
		}

		public function set colour(v:uint):void
		{
			_colour = v;
			invalidateDisplayList();
		}

		public function get hairLength():Number
		{
			return _hairLength;
		}

		public function set hairLength(v:Number):void
		{
			_hairLength = v;
			invalidateSize();
			invalidateDisplayList();
		}

		public function get minGap():Number
		{
			return _minGap;
		}

		public function set minGap(v:Number):void
		{
			_minGap = v;
			invalidateSize();
			invalidateDisplayList();
		}

		public function get size():Number
		{
			return _size;
		}

		public function set size(v:Number):void
		{
			_size = v;
			invalidateSize();
			invalidateDisplayList();
			
		}

		override protected function measure() : void
		{
			measuredWidth = Math.min(_minGap, _size) + (_hairLength * 2);
			measuredHeight = Math.min(_minGap, _size) + (_hairLength * 2);
		}
		
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
		{
			var g:Graphics = this.graphics;
			var gap:Number = Math.min(_minGap, _size);
			var endOffs:Number = (_hairLength + gap);
			g.clear();
			trace(_colour);
			g.lineStyle(1, _colour);
			g.moveTo(-endOffs, 0);
			g.lineTo(-gap, 0);
			g.moveTo(0, -endOffs);
			g.lineTo(0, -gap);
			g.moveTo(gap, 0);
			g.lineTo(endOffs, 0);
			g.moveTo(0, gap);
			g.lineTo(0, endOffs);
		}
		
	}
}